#!/bin/bash

# 数据库迁移工具构建脚本

# 检查是否安装了Python3
if ! command -v python3 &> /dev/null
then
    echo "未找到python3，请先安装python3"
    exit 1
fi

# 检查是否安装了pip
if ! command -v pip3 &> /dev/null
then
    echo "未找到pip3，请先安装pip3"
    exit 1
fi

# 安装构建依赖
echo "安装构建依赖..."
pip3 install pyinstaller

# 安装项目依赖
echo "安装项目依赖..."
pip3 install -r requirements.txt

# 使用PyInstaller打包，包含必要的隐式依赖
echo "开始打包..."
pyinstaller --onefile \
    --hidden-import=cryptography \
    --hidden-import=cryptography.x509 \
    --hidden-import=cryptography.hazmat.backends.openssl.backend \
    --hidden-import=cryptography.hazmat.bindings._openssl \
    --hidden-import=cryptography.hazmat.primitives.kdf \
    --hidden-import=cryptography.hazmat.primitives.kdf.pbkdf2 \
    --hidden-import=oracledb \
    --hidden-import=dmPython \
    --collect-all dmPython \
    --name oracle2dm main.py -p .

echo "打包完成！可执行文件位于 dist/oracle2dm"
echo "使用方法: ./dist/oracle2dm [配置文件路径]"